/*
 * Copyright 2023, Haiku, Inc.
 * Distributed under the terms of the MIT License.
 *
 * Authors:
 *		Haiku Team
 */
#ifndef CPU_LOONGARCH64_H
#define CPU_LOONGARCH64_H


#include <SupportDefs.h>


// LoongArch64 CPU 特性标志
#define LOONGARCH64_FEATURE_LSX      (1 << 0)  // 龙芯向量扩展 (LoongArch SIMD eXtension)
#define LOONGARCH64_FEATURE_LASX     (1 << 1)  // 龙芯高级向量扩展 (LoongArch Advanced SIMD eXtension)
#define LOONGARCH64_FEATURE_LBT      (1 << 2)  // 龙芯二进制翻译扩展 (LoongArch Binary Translation extension)
#define LOONGARCH64_FEATURE_COMPLEX  (1 << 3)  // 复数计算扩展
#define LOONGARCH64_FEATURE_CRYPTO   (1 << 4)  // 加密扩展
#define LOONGARCH64_FEATURE_VIRTUALIZATION (1 << 5)  // 虚拟化扩展

// CSR寄存器地址定义
#define LOONGARCH_CSR_CPUID      0x0           // CPU ID
#define LOONGARCH_CSR_PRCFG1     0x21          // 处理器配置信息1
#define LOONGARCH_CSR_PRCFG2     0x22          // 处理器配置信息2
#define LOONGARCH_CSR_PRCFG3     0x23          // 处理器配置信息3

#ifdef __cplusplus
extern "C" {
#endif

extern status_t loongarch64_identify_cpu(void);
extern void loongarch64_init_cpu(void);
extern uint32 loongarch64_get_cpu_features(void);
extern void loongarch64_set_cpu_features(uint32 features);
extern const char* loongarch64_get_cpu_vendor_string(void);
extern const char* loongarch64_get_cpu_model_string(void);

#ifdef __cplusplus
}
#endif

#endif	// CPU_LOONGARCH64_H